package com.qige.homework;

import java.util.Arrays;
import java.util.Scanner;

public class homework5 {
    public static void main(String[] args) {
        String[] strings = new String[6];
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < strings.length; i++) {
            System.out.println("请输入第" + (i+1) + "个字符串：");
            strings[i] = input.next();
        }
        System.out.println("源字符串: " + Arrays.toString(strings));
        int count = 0;
        for (int i = 0; i < strings.length; i++) {
            if (strings[i].length() > 5){
                strings[i] = null;
                count++;
            }
        }
        String[] strings1 = new String[strings.length - count];
        int index = 0;
        for (int i = 0; i < strings.length; i++) {
            if (strings[i] != null){
                strings1[index++] = strings[i];
            }
        }
        System.out.println("删除后:" + Arrays.toString(strings1));
    }
}
